home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / Macintosh Sample Code / SC.023.FracApp 2.0 / UAreaSelector.p < prev    next >
Encoding:
Text File  |  1990-04-30  |  3.7 KB  |  95 lines  |  [TEXT/MPS ]

  1. {[j=20/53/1$] Pasmat Options}
  2.  
  3. UNIT UAreaSelector;
  4.  
  5. {-------------------------------------------------------------------------------------------
  6.  
  7.     Program:    FracApp 2.0
  8.     Unit:        UAreaSelector
  9.     File:        UAreaSelector.p
  10.     Includes:    UAreaSelector,inc1.p
  11.  
  12.     by Keith Rollin & Bo3b Johnson
  13.     of Apple Macintosh Developer Technical Support
  14.  
  15.     Copyright © 1988-1990 Apple Computer, Inc.
  16.     All rights reserved.
  17.  
  18. --------------------------------------------------------------------------------------------
  19.  
  20.     This unit holds a command object that is used when we have a mouse down in the content
  21.     area of one of our FracAppViews. MacApp calls this to take care of mouse tracking. We
  22.     have a special mouse tracker for several reasons.
  23.  
  24.     For one, we’d like to use a different pattern when dragging the mouse around. The normal
  25.     gray pattern doesn’t show up too well on our colored backgrounds.
  26.  
  27.     Second, we need to constrain the dimensions of the rectangle that gets dragged out. By
  28.     doing this, we make sure that the rectangle that is ultimately defined is proportional
  29.     to the rectangle used for our document.
  30.  
  31.     Finally, after the rectangle is all drawn, and we lift the mouse up, we have to tell
  32.     the TFracAppView what the new selection is. This is because it is the view that knows
  33.     what is selected. When the mouse is lifted, we call the SetSelection method of the
  34.     view with the rectangle.
  35.  
  36.     TAreaSelector is a descendent of TNoChangesCommmand. TNoChangesCommand is a descendent
  37.     of TCommand that says that it doesn’t change the document, and so it can’t be undone.
  38.     All it does is have an INoChangesCommand that sets fCanUndo and fCausesChangs to
  39.     FALSE. Since we just track the mouse, and don’t change the state of the document or
  40.     view, we descend ourselves from TNoChangesCommmand.
  41.  
  42. --------------------------------------------------------------------------------------------}
  43.  
  44.     INTERFACE
  45.  
  46.         USES UMacApp, UDialog, QDOffScreen, ToolUtils, URectStack, UOffscreen,
  47.              UFracApp;
  48.  
  49.         TYPE
  50.             {-------------------------------  Command  -------------------------------}
  51.  
  52.             TAreaSelector        = OBJECT (TNoChangesCommand)
  53.  
  54.                 fOwnerView:         TFracAppView;    { The view we are tracking in. We need to
  55.                                                      keep track of this so we can tell the
  56.                                                      view to set its selection rectangle
  57.                                                      when we are all done. }
  58.                 fPlotHeight:        Longint;
  59.                 fPlotWidth:         Longint;        { The dimensions of the document we are
  60.                                                      tracking. These values let us know how
  61.                                                      to constrain mouse tracking, because we
  62.                                                      want it to be proportional to the
  63.                                                      document size. }
  64.  
  65.                 PROCEDURE TAreaSelector.IAreaSelector(itsView: TFracAppView;
  66.                                                       itsDocument: TFracAppDocument);
  67.                 { Initialize the selection object itself.  This basically sets up with
  68.                   ICommand, then sets our fields to remember our view. }
  69.  
  70.                 FUNCTION TAreaSelector.TrackMouse(aTrackPhase: TrackPhase; VAR anchorPoint,
  71.                                                   previousPoint, nextPoint: VPoint;
  72.                                                   mouseDidMove: BOOLEAN): TCommand; OVERRIDE;
  73.                 { Track the mouse while the button is down in the view. Sets the selection in
  74.                   the owning view when we are done. }
  75.  
  76.                 PROCEDURE TAreaSelector.TrackFeedback(anchorPoint, nextPoint: VPoint;
  77.                                                       turnItOn,
  78.                                                       mouseDidMove: BOOLEAN); OVERRIDE;
  79.                 { Feedback that matches better, using the selection pattern. }
  80.  
  81.                 PROCEDURE TAreaSelector.TrackConstrain(anchorPoint, previousPoint: VPoint;
  82.                                                        VAR nextPoint: VPoint); OVERRIDE;
  83.                 { Constrain the mouse movement to be a rect which matches the screen. }
  84.  
  85.                 PROCEDURE TAreaSelector.Fields(PROCEDURE
  86.                                                DoToField(fieldName: Str255; fieldAddr: Ptr;
  87.                                                          fieldType: Integer)); OVERRIDE;
  88.                 END;
  89.  
  90.     IMPLEMENTATION
  91.  
  92.         {$I UAreaSelector.inc1.p}
  93.  
  94. END.
  95.